﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace DuSQL.API
{
    public class Comm
    {
        public static List<DbConnect> MyConnections = new List<DbConnect>();

        public static TreeNode CurSelNode = new TreeNode();//当前选择的节点
        public static object FrameObj = new object();//frame传递的参数
        public  static event EventHandler ChangeDataEvent;
        public static void OnChangeData(object sender, EventArgs e)
        {
            if (ChangeDataEvent != null)
            {
                ChangeDataEvent(sender, e);
            }        
        }
    }
    public class DbConnect
    {
        public string ConnectID { get; set; }
        public DbConnect()
        {
            this.ConnectName = "db.mdb";
        }
     
        public string ConnectName { get; set; }//连接名称        
        public string ConnectStr { get; set; }//连接字符串
        public string[] DbElements { get; set; }
        public List<TableInfo> Tables { get; set; }
        public List<TableView> Views { get; set; }
        public List<Procedure> Procedures { get; set; }
        public NodeType DbType { get; set; }//类型
        public ConnectInfo ConnectInfo { get; set; }
    }

    public class ConnectInfo
    {
        public string HostName { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public string DataBaseName { get; set; }
    }
    public class TableInfo
    {
        public string Tablename { get; set; }
    }
    public class TableView
    {
        public string Tablename { get; set; }
    }
    public class Procedure
    {
        public string Name { get; set; }
    }
    public enum NodeType
    {
        DbConnection_Access,
        DbConnection_SqlServer,
        DbFolder_Table,
        DbFolder_View,
        DbFolder_Procedure,
        DbTable,
        DbView,
        DbProcedure,
        DbColumn
    }
   
    public struct TreeNode
    {
       public string name{get;set;}
        public  NodeType nodetype{get;set;}
    }

}
